calculateScaledDpCompose

internal fun calculateScaledDpCompose(baseValue: Float, configuration: Configuration, qualifier: DpQualifier, inverter: Inverter, ignoreMultiWindows: Boolean, applyAspectRatio: Boolean, customSensitivityK: Float?, context: Context? = null): Float

EN Shared pure-math scaling kernel used by toDynamicScaledDp and toDynamicScaledPx.

Algorithm summary:

  1. Applies Inverter rules to swap the effective DpQualifier based on orientation.

  2. If ignoreMultiWindows is true, detects split-screen via layout flags; if active, returns baseValue unchanged so the UI does not over-scale in a small window.

  3. For the common path (SMALL_WIDTH + DEFAULT inverter + no custom sensitivity), delegates to DimenCache.calculateRawScaling which reads the pre-computed factors from DimenCache.ScreenFactors — one float multiply, zero extra allocations.

  4. For other qualifiers or custom sensitivity, reads the screen dimension from Configuration and performs the scaling formula inline.

Performance: Simple paths without Aspect Ratio complete in ~2 ns (single multiply). Paths with Aspect Ratio require ~41 ns on Snapdragon 888 (includes ln() fallback). Results are memoized by the surrounding remember block and DimenCache.

PT Núcleo de escalonamento puro compartilhado por toDynamicScaledDp e toDynamicScaledPx.

Resumo do algoritmo:

  1. Aplica as regras de Inverter para trocar o DpQualifier efetivo conforme a orientação.

  2. Se ignoreMultiWindows for true, detecta split-screen via flags de layout; se ativo, retorna baseValue sem escalar.

  3. Para o caminho comum (SMALL_WIDTH + DEFAULT + sem sensibilidade customizada), delega para DimenCache.calculateRawScaling com os fatores pré-calculados.

  4. Para outros qualificadores ou sensibilidade customizada, lê a dimensão da tela do Configuration e executa a fórmula de escalonamento inline.

Return

Scaled Dp value as a raw Float (caller converts to Dp or pixels).

Parameters

baseValue

Raw Dp value to scale (e.g. 16f for 16 dp).

configuration

Current Configuration snapshot from LocalConfiguration.current.

qualifier

Original screen qualifier before inversion.

inverter

Orientation-swap rule.

ignoreMultiWindows

Whether to suppress scaling in multi-window mode.

applyAspectRatio

Whether to apply the AR multiplier.

customSensitivityK

Custom AR sensitivity constant, or null for the library default.